home *** CD-ROM | disk | FTP | other *** search
- Path: news.mindlink.net!news
- From: genew@mindlink.bc.ca (Gene Wirchenko)
- Newsgroups: comp.lang.c
- Subject: Re: What is wrong in this code?
- Date: Sat, 13 Jan 1996 22:27:15 GMT
- Organization: MIND LINK! - British Columbia, Canada
- Message-ID: <4d9bm7$nj7@fountain.mindlink.net>
- References: <DL2z7o.2K5@scisun.sci.ccny.cuny.edu> <4d7kvv$j8@ub239.dialup.uwa.edu.au>
- NNTP-Posting-Host: line224.nwm.mindlink.net
- X-Newsreader: Forte Free Agent 1.0.82
-
- prye@cyllene.uwa.edu.au (Peter Rye) wrote:
-
- >sergio@sci.ccny.cuny.edu (Sergio Rojas) writes:
-
- [snip]
- >>x = pow(x,x);
- > ^-------------------- This line is a problem.
- > I believe this will give rise to
- > "undefined behavior" because you
- > are modifying x using a function
- > which takes x as an argument.
- > Use something like y = pow(x,x);
- > Where y is declared as a double,
- > then use y in the printf below.
-
- Nope, the line isn't a problem from the C point of view. x gets
- changed only after pow() returns, so it isn't the evaluation order
- problem of x=x++, yech cetera.
-
- However, vars are cheap and using a different one for the result
- is clearer in non-trivial contexts.
-
- Sincerely,
-
- Gene Wirchenko
-
- C Pronunciation Guide:
- y=x++; "wye equals ex plus plus semicolon"
- x=x++; "ex equals ex doublecross semicolon"
-
-